<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>05_流程控制</title>
</head>
<body>
<script>
    //1.顺序结构
    console.log('1');
    console.log('2');
    console.log('3');
    //2.分支结构
    let uname='';
    if(!uname){
        // alert('请先登录！')
    }else {
        // alert('登录成功！'+uname);
    }
    //3.选择分支结构
    let gender=0;
    switch (gender) {
        case 1:
            console.log('性别：男');
            break;
        case 0:
            console.log('性别：女');
            break;
        default:
            console.log('性别：未知');
    }
    //4.循环结构
    let names=['张三','李四','王五'];
    for(var i=0;i<names.length;i++){
        console.log(names[i]);
    }
    //用var定义循环变量1，循环结束后在此处仍能打印出i值
    //但如果用let定义，就会报错：变量i不存在
    console.log(i);

    //5.增强for循环
    //let n为每轮循环取出的值names
    for(let n of names){
        console.log(n);
    }
</script>
</body>
</html>